package com.kmproject.haifu.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.kmproject.haifu.mvp.contract.MyStoreContract;
import com.kmproject.haifu.mvp.model.api.service.MemberCenterService;
import com.kmproject.haifu.mvp.model.api.service.StoryService;
import com.kmproject.haifu.mvp.model.api.service.UserService;
import com.kmproject.haifu.mvp.model.entity.ResultBean;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowBean;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.MemberCenterUserInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.MyStoreMainBean;
import com.kmproject.haifu.mvp.model.entity.beans.MyStoryBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 07/25/2019 13:45
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class MyStoreModel extends BaseModel implements MyStoreContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;
    MemberCenterService memberCenterService;
    StoryService storyService;
    UserService userService;
    @Inject
    public MyStoreModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
        memberCenterService=mRepositoryManager.obtainRetrofitService(MemberCenterService.class);
        storyService=mRepositoryManager.obtainRetrofitService(StoryService.class);
        userService=mRepositoryManager.obtainRetrofitService(UserService.class);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }


    @Override
    public Observable<ResultBean<List<HousePayWayBean>>> getAreaTree( String value, String category) {
        return memberCenterService.getAreaTree(value,category);
    }

    @Override
    public Observable<ResultBean<List<HousePayWayBean>>> dictList(String value, String category) {
        return storyService.dictList(value,category);
    }

    @Override
    public Observable<ResultBean<MyStoreMainBean>> getStoreInfo(String storeId) {
        return storyService.getStoreInfo(storeId);
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> listHouseRentByStore( Map<String, Object> mps) {
        return storyService.listHouseRentByStore(creatRequestBody(mps,mGson));
    }

    @Override
    public Observable<ResultBean> removeHouseRent(String rentId) {
        return userService.removeHouseRent(rentId);
    }

    @Override
    public Observable<ResultBean> lowerShelfHouseRent(String rentId, String lowerShelfReason) {
        return userService.lowerShelfHouseRent(rentId,  lowerShelfReason);
    }

    @Override
    public Observable<ResultBean<List<HousePayWayBean>>> getAreaTree(String url, String value, String category) {
        return userService.getAreaTree(url,value,category);
    }
    @Override
    public Observable<ResultBean<List<HousePayWayBean>>> getHousePayWayBean(String url, String value, String category) {
        return userService.dictList(url,value,category);
    }
    @Override
    public Observable<ResultBean<List<HousePayWayBean>>> getQueryConditionTree(String houseCategory, String rentType) {
        return userService.getQueryConditionTree(houseCategory, rentType);
    }

    @Override
    public Observable<ResultBean<MemberCenterUserInfoBean>> getMemberLevelByUser() {
        return mRepositoryManager.obtainRetrofitService(MemberCenterService.class).getMemberLevelByUser();
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowBean>>> getHouseRentList(Map<String, Object> params) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).getHouseRentByCurrentStore(creatRequestBody(params,mGson));
    }

    @Override
    public Observable<ResultBean> userAttentionAdd(Map<String, Object> params) {
        return userService.userAttentionAdd(creatRequestBody(params,mGson));
    }

    @Override
    public Observable<ResultBean> userAttentionCancel(Map<String, Object> params) {
        return userService.userAttentionCancel(creatRequestBody(params,mGson));
    }
}